
"""
对初始的训练图片进行平移，翻转，增强数据集

"""

import cv2
import glob
import os
import numpy as np
from math import sin, fabs, radians, cos
from dicom.rotate import get_rotated_img

def pan(img_path):
    """图像平移"""

    img = cv2.imread(img_path, cv2.COLOR_GRAY2RGB)
    print(img.shape)
    # 平移矩阵[[1,0,-100],[0,1,-12]]
    M = np.array([[1, 0, -100], [0, 1, 0]], dtype=np.float32)
    img_change = cv2.warpAffine(img, M, (368, 368))
    res = np.hstack((img, img_change))
    print(img_change.shape)

    cv2.imshow("test", res)
    cv2.waitKey(0)

def flip(img_path):
    """镜像"""

    img = cv2.imread(img_path)
    cv2.imshow("original", img)

    # 水平镜像
    h_flip = cv2.flip(img, 1)
    cv2.imshow("Flipped Horizontally", h_flip)

    # 垂直镜像
    v_flip = cv2.flip(img, 0)
    cv2.imshow("Flipped Vertically", v_flip)

    # 水平垂直镜像
    hv_flip = cv2.flip(img, -1)
    cv2.imshow("Flipped Horizontally & Vertically", hv_flip)

    cv2.waitKey(0)

def rotate():
    """图像旋转"""
    pass

def data_enhance(image_path):
    """数据增强"""

    dcm_paths = glob.glob(os.path.join(image_path, "**", "**.jpg"))
    for p in dcm_paths:
        pass


if __name__ == '__main__':
    img_path = './dataset/SparkAI/train/train_data/001L0/L0000.jpg'
    coords_list = []
    img, coords_rotated_list = get_rotated_img(img_path, coords_list, 10)
